package com.szgr.baoyin.myview;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.view.View;

/**
 * Created by Jimbo on 2015/9/21.
 */
public class CircleView extends View {
    public int index;
    private static final Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    public int circleRadius;
    public int color = Color.WHITE;
    public CircleView(Context context, int index,int circleRadius){
        this(context);
        this.index = index;
        this.circleRadius = circleRadius;
        mPaint.setStrokeWidth(2);
    }
    public CircleView(Context context) {
        super(context);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        if(isSelected()){
            mPaint.setStyle(Paint.Style.FILL);
        }else{
            mPaint.setStyle(Paint.Style.STROKE);
        }
        mPaint.setColor(color);
        //绘制空心圆
        canvas.drawCircle(getWidth() / 2, getHeight() / 2, circleRadius, mPaint);
    }
}
